package dao

import (
	"gin-web/app/model"
)

type userDao struct{}

var (
	User = userDao{}
)

//gorm文档库  https://www.jianshu.com/p/61bfd3bcd90e
func (dao *userDao) FindOneByWorkcode(workcode string) (*model.User, error) {
	u := new (model.User)
	err := db.Where("workcode = ?", workcode).First(u).Error
	if err != nil {
		return nil, err
	}

	return u, nil
}

func (dao *userDao) FindOneByUserAndPwd(username string, password string) (*model.User, error) {
	u := new (model.User)
	err := db.Where("name = ?", username).Where("password", password).First(u).Error
	if err != nil {
		return nil, err
	}

	return u, nil
}
